<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" id="i1">
<input type="button" value="猜一下" onclick="f()">
<div></div>

<script>
  let x = parseInt(Math.random()*100)+1;
  let c = 0;

  function f() {
    c++;
    let i1 = document.querySelector("#i1")
    let d = document.querySelector("div")

    if (i1.value>x){
      d.innerText="猜大了"
    }else if(i1.value<x){
      d.innerText="猜小了"
    }else{d.innerText="第"+c+"次猜对了"}
  }
</script>
</body>
</html>
